<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>Project CutList and Layout</title>
  <script type="text/javascript" src="wz_jsgraphics.js"></script>
  <link rel="stylesheet" href="result.css" TYPE="text/css" MEDIA="screen">
  <link rel="stylesheet" href="print.css" TYPE="text/css" MEDIA="print"> 
  <SCRIPT>

var results;
var modelName;

//function handleResults(inResults, inModelName){
function handleResults(inResults){
  //document.title = inModelName;
  <!-- enable the print cutlist button, disable the print layout button  -->
  var buttonDivObject = document.getElementById('printLayout');
  buttonDivObject.style.visibility = "hidden";
  var buttonDivObject = document.getElementById('printCutlist');
  buttonDivObject.style.visibility = "visible";

  document.getElementById('resultDiv').innerHTML = inResults;
  var resultDivObject = document.getElementById('resultDiv');
  resultDivObject.style.visibility = "visible";
  resultDivObject.style.height = "500px";
  //modelName = inModelName;
  results = inResults;
  //debug the generated script - print to another window
  //debugWin();
}

function debugWin(){ 
  debugWindow = window.open('','_blank'); 

  var guts =document.documentElement.innerHTML; 
  var match = "<"; 

  var re = new RegExp("<", "g"); 

  var newguts = guts.replace(re, "&lt;"); 

  debugWindow.document.write(newguts ); 
}

function debugSaveHtml() {
  var w = window.frames.w;
  if( !w )
  {
    w = document.createElement( 'iframe' );
    w.id = 'w';
    w.style.display = 'none';
    document.body.insertBefore( w, null );
    w = window.frames.w;
    if( !w )
    {
      w = window.open( '', '_temp', 'width=100,height=100' );
      if( !w )
      {
	window.alert( 'Sorry, the file could not be created.' );
      }
    }
  }
  
  var d = w.document;
  name = "testhtml.txt";
  d.open( 'text/plain', 'replace' );
  d.write( results );
  d.close();
  if( d.execCommand( 'SaveAs', null, name ) )
  {
    window.alert( name + ' has been saved.' );
  }
 w.close();
}

//function handleLayoutScript(inScript, inModelName){
//  document.title = inModelName;
function handleLayoutScript(inScript){
//  document.title = inModelName;
  //var title = document.getElementsByTagName("title")[0];
  <!-- Create a script DOM element with the inScript as the script text -->
  <!-- Place the script element into the head element-->
  var head = document.getElementsByTagName("head")[0];
  var scriptObj = document.createElement("script");

  scriptObj.setAttribute("type", "text/javascript");
  scriptObj.setAttribute("text", inScript);  
  head.appendChild(scriptObj);
  
  <!-- set the layout div visible and set the height -->
  //var layoutDivObject = document.getElementById('layoutDiv');
  //layoutDivObject.style.visibility = "visible";
  //layoutDivObject.style.height = "650px";
  <!--layoutDivObject.style.position = "relative";
  
  <!-- disable the print cutlist button, enable the print layout button  -->
  var buttonDivObject = document.getElementById('printLayout');
  buttonDivObject.style.visibility = "visible";
  var buttonDivObject = document.getElementById('printCutlist');
  buttonDivObject.style.visibility = "hidden";
  
  <!-- Then call the drawLayout() function which our script must have defined ( if it didn't then I'm sure there will be an error) -->
  <!-- This will draw in layoutDiv as a canvas because our scripts generated by Cutlist plugin( which is pass to the html code in inScript)  -->
  <!-- calls jsgraphics specifying the canvas to use -->
  drawLayout();
  
  <!-- Now store the generated html from the jsgraphics script we just ran, to our results variable. This will be used later for printing
  <!-- ( jg_result_html is a variable inside the jsgraphcs script)-->
  results = "";
  results = jg_result_html;
  
  <!-- debug - print the dynamic script and html to a separate window -->
  //debugWin();
  
  <!-- debug - print the results to a file -->
  //debugSaveHtml()
}
 
function handleClose(){
	window.location='skp:handleClose@x';
}

  </SCRIPT>
</head>
<body> 
<!-- The divs are both hidden and set visible by the appropriate input handler when needed. Style is controlled  through results.css-->
<div id='resultDiv' class='result'>
</div>
<div id='layoutDiv' class='layout'>
</div>
<div id="buttons">
<table width="200" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td><input id="printLayout" name="printLayout" type="button" value="Print Layout" onClick="javascript:window.print();"></td>
    <td><input id="printCutlist" name="printCutlist" type="button" value="Print Cutlist" onClick="javascript:window.print();"></td>
    <td><input id="close" name="close" type="button" value="Close" onClick="javascript:handleClose();"></td>
  </tr>
</table>
</div>
</body>
</html>
